package com.tim.soundseechina;

import java.util.List;

import com.tim.framework.common.PageProperty;
import com.tim.soundseechina.entity.InformationInfo;
import com.tim.soundseechina.service.IInformationInfoService;
import com.tim.soundseechina.service.impl.InformationInfoServiceImpl;

public class UpdateDataInfo {
	public static void main(String[] args) {
		// 获取Bean
		IInformationInfoService informationService = (InformationInfoServiceImpl) SoundSeeChina.factory
				.getBean("informationInfoService");
		PageProperty pp = new PageProperty();
		pp.setNpagesize(0);
		List<InformationInfo> infoList = informationService.getList(pp);
		for (int i = 0; i < infoList.size(); i++) {
			InformationInfo info = infoList.get(i);
			String title = info.getTitle();
			String desc = info.getInformationDesc();
			if (title != null && title.indexOf("•") != -1) {
				info.setTitle(title.replace("•", "-"));
			}
			if (desc != null && desc.indexOf("•") != -1) {
				info.setInformationDesc(desc.replace("•", "-"));
			}
			informationService.update(info);
		}
	}

	public static String getTempString(String content, String splitor) {
		if ((content.indexOf(splitor) > -1 && content.indexOf(splitor) < 10)
				|| (content.indexOf(splitor.toUpperCase()) > -1 && content
						.indexOf(splitor.toUpperCase()) < 10)) {
			content = StringUtil.getStringFromPattern(content, ">(.*)</");
		}
		return content;
	}

	public static String replaceString(String content, String oldStr,
			String newStr) {
		if (content.indexOf(oldStr) != -1) {
			content = content.replaceAll(oldStr, newStr);
		}
		return content;
	}
}
